const glob = require("glob");
const fs = require("fs");
// 适配window和linux的结尾符不一致问题
const basePaths = glob.glob.sync(`./**`, {
    nodir: true,
    dot: true,
});
if(basePaths && basePaths.length >0){
    basePaths.forEach((path) =>{
        if( !path.startsWith('./.') && 
            !path.startsWith('./node_modules') && 
            !path.startsWith('./asset/public') && 
            !path.startsWith('./asset/src/assets') && 
            !path.startsWith('./out')){
            fs.readFile(path, 'utf8', (err, content) => {
            if (err) {
                console.error(`${path}读取失败`);
            }
            const newContent = content.replace(/\r\n/g,'\n');
            fs.writeFile(path, newContent, err => {
                if (err) {
                    console.error(`${path}写入失败`);
                }
              });
            });
        }
    })
}